package com.softserveinc.moviedbapp.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.softserveinc.moviedbapp.fragment.MovieListFragment;
import com.viewpagerindicator.TitleProvider;

import java.util.List;

public class MovieListFragmentAdapter extends FragmentPagerAdapter implements TitleProvider {

	private final List<MovieListFragment> mMovieListFragments;
	static final String[] CONTENT = new String[] { "by title", "by release date", "by rating" };

	private static String TAG = MovieListFragmentAdapter.class.getSimpleName();
	private static final boolean DEBUG = false;

	public MovieListFragmentAdapter(final FragmentManager fm, final List<MovieListFragment> fragments) {
		super(fm);
		mMovieListFragments = fragments;

		if (DEBUG) {
			Log.i(TAG, "MovieListFragmentAdapter(fm) constructor");
		}
	}

	@Override
	public Fragment getItem(final int position) {
		if (DEBUG) {
			Log.i(TAG, "getItem(final int position) pos = " + position);
		}
		return mMovieListFragments.get(position);
	}

	@Override
	public int getCount() {
		if (DEBUG) {
			Log.i(TAG, "getCount()");
		}
		return mMovieListFragments.size();
	}

	@Override
	public int getItemPosition(final Object object) {
		if (DEBUG) {
			Log.i(TAG, "getItemPosition(final Object object) = " + POSITION_NONE);
		}
		return POSITION_NONE;
	}

	@Override
	public String getTitle(final int position) {
		if (DEBUG) {
			Log.i(TAG, "getTitle(final int position) pos = " + position);
		}
		return CONTENT[position];
	}
}
